package com.yoso.shop.infrastructure.config;

import com.alibaba.fastjson.JSON;
import com.yoso.api.info.log.OrderLogInfo;
import com.yoso.base.infrastructure.exception.BaseException;
import lombok.Data;
import org.springframework.amqp.core.ExchangeTypes;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.QueueBinding;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.amqp.support.converter.Jackson2JsonMessageConverter;
import org.springframework.amqp.support.converter.MessageConverter;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.nio.charset.StandardCharsets;
import java.util.Optional;

/**
 * @author shizejin
 * @date 2022/1/28
 * @description:
 */
@Configuration
@Data
public class RabbitmqConfig {
    /**
     * 订单日志交换机
     */
    @Value("${rabbitmq.exchange.log.shop.order}")
    private String orderLogExchange;
    /**
     * 库存日志交换机
     */
    @Value("${rabbitmq.exchange.log.shop.stock}")
    private String stockLogExchange;
    /**
     * 订单延时确认交换机
     */
    @Value("${rabbitmq.exchange.delay.shop.order}")
    private String delayOrderConfirmExchange;

    /**
     *
     * @return mq传递正常的json格式
     */
    @Bean
    public MessageConverter messageConverter(){
        return new Jackson2JsonMessageConverter();
    }


}
